package com.wulaobo.partition;

import org.apache.flink.api.common.functions.Partitioner;

/**
 * @Author wuwenbo
 * @Date 2024/5/24 9:52
 * @ClassName: MyPartitioner
 * @Description: 自定义分区器
 */
public class MyPartitioner implements Partitioner<String> {

    public MyPartitioner() {
        System.out.println("创建了MyPartitioner对象");
    }

    @Override
    public int partition(String key, int numPartitions) {
        System.out.println("numPartitions: " + numPartitions);
        return Integer.parseInt(key) % numPartitions;
    }
}
